From : Steve Matty (Big.Will.Riker@ldngedge.demon.co.uk)
Subject : How to implement a starfield
hmm..this source might help...


;Attached sourcecode follows
;! TO RUN THIS CODE YOU MUST USE THE TWO FOLLOWING RESIDENT FILES :
;
;   bb2objtypes.res
;   sbra.res 
;
 

#SPEEDTEST=0
#numstars =5000
#OLDMODE  =1

DEFTYPE.l bitm,bitplane,plotad

NEWTYPE .dotplot
  byte_spd.w
  bit.w
  byte_pos.w
End NEWTYPE

DEFTYPE.dotplot *plots

Statement assembler_cls{a.l}
  MOVE.l d0,a0:ADD.l #10240,a0
  MOVEQ #0,d0:MOVEQ #0,d1:MOVEQ #0,d2:MOVEQ #0,d3:MOVEQ #0,d4
  MOVEQ #0,d5:MOVEQ #0,d6:MOVE.l d0,a1:MOVE.l d0,a2:MOVE.l d0,a3
  MOVE #255,d7
  loop1:MOVEM.l d0-d6/a1-a3,-(a0):DBRA d7,loop1
  AsmExit
End Statement

#playfield_height=256
#playfield_y_end=256
Statement DoStars {plotad.l,bitplane.l}
; Lowres bitmap star field drawer
;d0=table
;d1=bitplane
._DrawStarField:
  MOVE.l    d0,a0
  MOVE.l    d1,a1
'loop
  MOVE.w    (a0)+,d0
  !SBMI     {'theend}
  MOVE.w    (a0)+,d1
  MOVE.w    (a0),d2

  CNIF      #OLDMODE
  BCLR      d1,0(a1,d2.w)
  CEND

  ADD.w     d0,d2
  CMPI.w    #playfield_y_end*40,d2
  !SBLT     {'no_y_shift}
  SUB.w     #playfield_height*40,d2
'no_y_shift:
  MOVE.w    d2,(a0)+
  BSET      d1,0(a1,d2.w)
  !SBRA     {'loop}
'theend:
  AsmExit
End Statement

Gosub Init
Gosub InitStars

BLITZ

Use BitMap 0

.Main
Repeat
  CNIF #SPEEDTEST
  Repeat:Until VPos=100
  MOVE.w  #$f00,$dff180
  CEND

  CNIF #OLDMODE=0
    assembler_cls{bitplane}
  CEND
  If VPos>250 OR VPos<44
  VWait
  EndIf
  DoStars{plotad,bitplane}

  CNIF #SPEEDTEST
  MOVE.w  #$000,$dff180
  CEND
Until JFire(2) OR JFire(1)
AMIGA
End

.Init:
  AGAPalRGB 0,1,255,255,255
  BitMap 0,320,256,2
  bitm.l=Addr BitMap(0)
  bitplane.l=Peek.l(bitm+8)

  InitCopList 0,44,256,$13001,8,2,0
  DisplayBitMap 0,0
  DisplayPalette 0,0
  BLITZ
  CreateDisplay 0
Return

.InitStars:
  Reserve 0,(#numstars+1)*SizeOf.dotplot
  plotad=Start(0)
  *plots=plotad
  For h=0 To #numstars-1
    x=Int(Rnd(320))
    *plots\byte_pos=(Int(Rnd(#playfield_height)))*40
    *plots\byte_pos+x/8
    *plots\byte_spd=(Int(Rnd(3))+1)*40
    *plots\bit=(NOT(x) AND %111)
    *plots+SizeOf.dotplot
  Next h
  *plots\byte_spd=-1
Return